package com.niit.service.impl;

import java.util.List;

import com.niit.bean.Log;
import com.niit.dao.LogDao;
import com.niit.dao.impl.LogDaoImpl;
import com.niit.service.LogService;
import com.niit.utils.Page;

public class LogServiceImpl implements LogService {
	
	private LogDao dao = new LogDaoImpl();
	@Override
	public int add(Log t) {
		return dao.add(t);
	}

	@Override
	public int delete(Log t) {
		return dao.delete(t);
	}

	@Override
	public int update(Log t) {
		return dao.update(t);
	}

	@Override
	public Page<Log> getPage(String pagenum, String url) {
		int total = dao.findTotal();//查出总记录数
		Page<Log> page = null;
		if(pagenum == null){
			page = new Page<Log>(total,1);
		}else{
			page = new Page<Log>(total, Integer.parseInt(pagenum));
		}
		List<Log> list = dao.findAll(page.getStartIndex(), page.getEndIndex());
		page.setList(list);
		page.setUrl(url);
		return page;
	}

}
